package com.googlecode.dgwt.client.dijit.base.state;

import com.google.gwt.user.client.Event;
import com.googlecode.dgwt.client.dijit.Dijit;
import com.googlecode.dgwt.client.dijit.Widget;

/**
 * @author wellsantos@wellsantos.com
 * @since 0.01
 */
public class FocusedState extends EventState {

    private static FocusedState instance;
    
    
    public static FocusedState get() {
        if (instance == null) {
            instance = new FocusedState();
        }
        return instance;
    }
    
    
    private FocusedState() {
    }
    
    @Override
    public boolean isActivatedBy(Event event, int eventMask, Widget widget) {
        return (eventMask & Event.ONFOCUS) != 0;
    }
    
    @Override
    public boolean isDeactivatedBy(Event event, int eventMask, Widget widget) {
        return (eventMask & Event.ONBLUR) != 0;
    }
    
    @Override
    protected String getDependentStyleClass() {
        return Dijit.getTheme().getFocusedName();
    }

    @Override
    public int getEventMask() {
        return Event.ONFOCUS | Event.ONBLUR;
    }

}
